﻿<Window x:Class="SBPweb.Presentation.WpfTestApp1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SBPweb.Presentation.CompleteMesh.Primitives;assembly=SBPweb.Presentation.CompleteMesh"
    Title="Main window"
    Width="800"
    Height="600">
    <Grid
        VerticalAlignment="Stretch" 
        HorizontalAlignment="Stretch">
        
        <Grid.Resources>
            <local:SphereMesh
                x:Key="SphereMeshSource1"
                Radius="20"
                Separators="10" />
            <local:CubeMesh
                x:Key="CubeMeshSource1"
                Width="40" />
            <MeshGeometry3D
                x:Key="SphereMesh1"
                Positions="{Binding Source={StaticResource SphereMeshSource1}, Path=Points}"
                TriangleIndices="{Binding Source={StaticResource SphereMeshSource1}, Path=TriangleIndices}"/>
            <MeshGeometry3D
                x:Key="SphereMesh2"
                Positions="{Binding Source={StaticResource SphereMeshSource1}, Path=Points}"
                TriangleIndices="{Binding Source={StaticResource SphereMeshSource1}, Path=TriangleIndices}"/>
            <MeshGeometry3D
                x:Key="CubeMesh1"
                Positions="{Binding Source={StaticResource CubeMeshSource1}, Path=Points}"
                TriangleIndices="{Binding Source={StaticResource CubeMeshSource1}, Path=TriangleIndices}"/>
        </Grid.Resources>
        
        <Viewport3D Name="vpMain"
                    Grid.Column="1"
                    Grid.Row="1" 
                    VerticalAlignment="Stretch" 
                    HorizontalAlignment="Stretch"
                    AllowDrop="True"
                    Focusable="True" Cursor="Hand">
                    
            <Viewport3D.Camera>
                <PerspectiveCamera
                    x:Name="camMain"
                    Position="100 30 0" 
                    LookDirection="-50 -15 0" 
                    UpDirection="0,1,0"
                    FieldOfView="90"
                />
            </Viewport3D.Camera>
            
            <ModelVisual3D>
                <ModelVisual3D.Content>
                   
                    <Model3DGroup>

                        <AmbientLight
                            Color="#808080" />
                        
                        <DirectionalLight
                            Color="#FFFFFF" 
                            Direction="0 +30 0" />
                        
                        <DirectionalLight
                            Color="#888888" 
                            Direction="0 -30 0" />

                        <GeometryModel3D
                            Geometry="{StaticResource SphereMesh1}">
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <SpecularMaterial Brush="#FFFFFF" />
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush
                                                ImageSource="/SBPweb.Presentation.WpfTestApp1;component/Resources/Image1.png"
                                                ViewportUnits="Absolute"
                                                Opacity="1.0"
                                                TileMode="None"
                                                Stretch="None" ViewboxUnits="Absolute" Viewport="-1,-1,1,1" Viewbox="-1,-1,0,1" AlignmentX="Left" AlignmentY="Top" />
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                        </GeometryModel3D>

                        <GeometryModel3D
                            Geometry="{StaticResource SphereMesh2}">
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <SpecularMaterial Brush="#FFFFFF" />
                                    <DiffuseMaterial Brush="#00FF00" />
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                            <GeometryModel3D.Transform>
                                <Transform3DGroup>
                                    <ScaleTransform3D
                                        x:Name="Sphere2Scaling"
                                        ScaleX="0.5"
                                        ScaleY="0.5"
                                        ScaleZ="0.5"
                                    />
                                    <TranslateTransform3D 
                                        x:Name="Sphere2Translation"
                                        OffsetZ="50"
                                    />
                                </Transform3DGroup>
                            </GeometryModel3D.Transform>
                        </GeometryModel3D>
                        
                        <!--GeometryModel3D
                            Geometry="{StaticResource CubeMesh1}">
                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial Brush="#00FF00" />
                                </MaterialGroup>
                            </GeometryModel3D.Material>
                        </GeometryModel3D-->

                    </Model3DGroup>

                </ModelVisual3D.Content>
            </ModelVisual3D>
            
        </Viewport3D>
    </Grid>
</Window>
